import CommonUtils from './common-utils'
import CRC from './crc.js'

export default {
	format0ECmd(deviceId, code, value, paramGroup) {
		var cmd = '5A';
		var verCode = '4D530E0009'
		if (paramGroup == '一级参数') {
			verCode += '10';
		} else if (paramGroup == '二级参数') {
			verCode += '20';
		} else if (paramGroup == '三级参数') {
			verCode += '30';
		} else {
			verCode += '10';
		}
		verCode += CommonUtils.str_pad("00000000", deviceId.toString(16));
		verCode += CommonUtils.str_pad("00", code.toString(16));
		verCode += '01';
		verCode += CommonUtils.str_pad("0000", parseInt(value).toString(16))
		cmd += verCode;
		cmd += CRC.ToCRC16(CommonUtils.str2Bytes(verCode));
		cmd += '4D';
		return cmd;
	},
	format0FCmd(deviceId, code, value) {
		var cmd = '5A';
		var verCode = '4D530F000B'
		verCode += CommonUtils.str_pad("00000000", deviceId.toString(16));
		verCode += '01';
		verCode += CommonUtils.str_pad("00", code.toString(16));
		verCode += '01';
		verCode += CommonUtils.str_pad("00000000", parseInt(value).toString(16))
		cmd += verCode;
		cmd += CRC.ToCRC16(CommonUtils.str2Bytes(verCode));
		cmd += '4D';
		return cmd;
	},

}
